class Solution:
    def plusOne(self, digits: list[int]) -> list[int]:
        index = len(digits) - 1
        while True:
            if index == -1:
                digits = [1] + digits
                return digits
            if digits[index] == 9:
                digits[index] = 0
                index -= 1
            else:
                digits[index] += 1
                return digits
            

if __name__ == '__main__':
    s = Solution()
    print(s.plusOne([9,9]))